<template>
  <div class="information">
    <titleText title="我的设备"></titleText>
    <div class="list" v-loading="loading">
      <div class="item" v-for="(item, index) in deviceList" :key="index">
        <div class="item_le">
          <div class="item_le_1">设备名称：{{ item.shebeibianhao }}</div>
          <div class="item_le_2">绑定时间：{{ item.create_time }}</div>
        </div>
        <div class="item_ri" @click="openKefu">联系客服解绑</div>
      </div>
      <div class="no_data" v-if="deviceList.length == 0 && !loading">
        <img class="no_img" src="../../assets/default/12.png" alt="" />
      </div>
    </div>
  </div>
  <kefu ref="kefuText"></kefu>
</template>

<script name="myDevice" setup>
import { post661a2c705eeba } from "@/utils/api.js";
import titleText from "./titleText.vue";
import kefu from "@/components/kefu.vue"
import { ref, onMounted } from "vue";
onMounted(() => {
  getList();
});

let deviceList = ref([]);
let loading = ref(true);
function getList() {
  post661a2c705eeba({})
    .then((res) => {
    //   console.log(res);
      loading.value = false;
      if (res.code == 1) {
        deviceList.value = res.data;
      }
    })
    .catch((err) => {
      console.log(err);
    });
}

let kefuText = ref(null);
function openKefu() {
  kefuText.value.openPopup();
}
</script>

<style lang="scss" scoped>
.information {
  padding: 18px 16px;
  background: #fff;
  min-height: 437px;
  .list {
    padding-top: 13px;
    .item {
      margin-bottom: 10px;
      background: #f6f7f9;
      border-radius: 3px;
      padding: 11px 12px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      .item_le {
        display: flex;
        flex-direction: column;
        justify-content: center;
        .item_le_1 {
          font-size: 8px;
          font-weight: 500;
        }
        .item_le_2 {
          font-size: 7px;
          color: #999999;
          margin-top: 7px;
        }
      }
      .item_ri {
        width: 66px;
        height: 16px;
        background: #1f52ae;
        border-radius: 2px;
        font-size: 7px;
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
      }
    }
  }
}
</style>